//
//  VBMainViewController.swift
//  VBo
//
//  Created by 赵世得 on 2016/10/22.
//  Copyright © 2016年 Zh. All rights reserved.
//

import UIKit

class VBMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let tabBar = VBTabBar()
        tabBar.click={
            print("===========")
        }
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(vc: VBHomeViewController(), title: "首页", img: "tabbar_home")
        addChildViewController(vc: VBMassageViewController(), title: "消息", img: "tabbar_message_center")
        addChildViewController(vc: VBDiscoverViewController(), title: "发现", img: "tabbar_discover")
        addChildViewController(vc: VBProfileViewController(), title: "我", img: "tabbar_profile")
    }
    
    private func addChildViewController(vc: UIViewController, title: String, img: String){
        vc.title = title
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orange], for: UIControlState.selected)
        vc.tabBarItem.image = UIImage(named: img)
        vc.tabBarItem.selectedImage = UIImage(named: "\(img)_selected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        let nav = VBNavigationViewController(rootViewController: vc)
        addChildViewController(nav)
        
        
    
    }

}
